﻿
namespace ReactionTest
{
    internal class Program
    {
        enum Direction
        {
            Up,
            Down,
            Left,
            Right
        }
        ConsoleKey input;
        static void Main(string[] args)
        {
            ConsoleKey input;
            Console.WriteLine("请输入需要测试的次数");
            int countoftest = Convert.ToInt32(Console.ReadLine());
            double totaltime = 0;
            int countoferror = 0;
            Random random = new Random();
            for (int i = 0; i < countoftest; i++)
            {
                DateTime dateTimestart = DateTime.Now;
                Console.WriteLine($"第{i}次测试");
                Direction direction = (Direction)random.Next(0, 4);
                do
                {
                    Console.WriteLine("请输入" + direction.ToString());
                    input = Console.ReadKey().Key;
                    if (direction == Direction.Up)
                    {
                        if (input == ConsoleKey.UpArrow)
                        {
                            Console.WriteLine("正确哒！");
                            break;
                        }
                        else Console.WriteLine("出错了呜呜");
                        countoferror++;
                        continue;
                    }
                    if (direction == Direction.Down)
                    {
                        if (input == ConsoleKey.DownArrow)
                        {
                            Console.WriteLine("正确哒！");
                            break;
                        }
                        else Console.WriteLine("出错了呜呜");
                        countoferror++;
                        continue;
                    }
                    if (direction == Direction.Left)
                    {
                        if (input == ConsoleKey.LeftArrow)
                        {
                            Console.WriteLine("正确哒！");
                            break;
                        }
                        else Console.WriteLine("出错了呜呜");
                        countoferror++;
                        continue;
                    }
                    if (direction == Direction.Right)
                    {
                        if (input == ConsoleKey.RightArrow)
                        {
                            Console.WriteLine("正确哒！");
                            break;
                        }
                        else Console.WriteLine("出错了呜呜");
                        countoferror++;
                        continue;
                    }
                } while (true);
                DateTime dateTimeOver = DateTime.Now;
                totaltime += (dateTimeOver - dateTimestart).TotalSeconds;
            }
            Console.WriteLine($"总共进行{countoftest}次测试，共用时{totaltime}秒，共错误{ countoferror}次");
        }
    }
}